<template>
	<view class="container">
		<view class="list_con">
			<view class="list_item" v-for="(item, index) in itemList" :key='index'>
				<!-- <image class="icon" src="../../../static/common/login/weixin.png"></image> -->
				<view class="center">
					<view class="center_row">
						<text style="font-size: 32rpx;font-weight: bold;">{{item.sceneLabel}}</text>
						<view>
							<text v-if="item.changeWay == 'add'" style="font-weight: bold;color: #56ac77;font-size: 32rpx;">{{'+' + item.money}}</text>
							<text v-else-if="item.changeWay == 'sub'" style="font-weight: bold;color: #ff0000;font-size: 32rpx;">{{'-' + item.money}}</text>
							<text v-else style="font-weight: bold;color: #999;font-size: 32rpx;">{{item.money}}</text>
						</view>
					</view>
					<view class="center_row" style="margin-top: 10rpx;">
						<text style="color: #999999;">{{$time.dateFormat('yyyy-mm-dd HH:MM:SS', item.createTime)}}</text>
						<view style="color: #999999;">余额{{ item.balanceIncomes }}</view>
					</view>
					<text style="color: #999999;margin-top: 20rpx;">来自会员{{item.fromUserModel.nickname}}({{item.fromUserModel.code}})</text>
					
				</view>
				<!-- <view class="right">
					<text :style="{color: item.type == 'add' ? '#d4a781' : '#000000'}">{{item.type == 'add' ? '+' + item.money : '-' + item.money}}</text> -->
			</view>
		</view>
		<u-empty text="暂无记录" mode="list" v-if="itemList.length < 1"></u-empty>
	</view>
</template>

<script>
	import {wallet} from '@/api/wallet.js'
	import {user} from '@/api/user.js'
	import { interfaceApi } from '@/api/interface.js'
	export default{
		data() {
			return {
				page: 1,
				size: 10,
				totalPage: 0,
				itemList: [],
				orderType: '',
				userInfo: {incomes: 0.00},
				optionDict: {}
			}
		},
		onLoad() {
		},
		onShow() {
			this.page = 1
			this.getWalletRecord()
		},
		onPullDownRefresh() {
			this.page = 1
			this.getWalletRecord()
		},
		onReachBottom() {
			console.log('上拉加载更多')
			if (this.page == 0) {
				return
			}
			this.getWalletRecord()
		},
		methods:{
			getWalletRecord(){
				wallet.getWalletRecord({
					page: this.page,
					size: this.size,
					user: this.$storage.getStorageDataSync(this.$store.state.userInfo).id,
					payway: 'balance'
				}).then(res => {
					uni.stopPullDownRefresh();
					if(res.data.code == 10000){
						if(this.page == 1){
							this.itemList = []
						}
						var list = res.data.data.list
						this.itemList = [...this.itemList, ...list]
						if (res.data.data.next) {
							this.page += 1
						} else {
							this.page = 0
						}
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.container{
		height: 100vh;
		padding-bottom: 60rpx;
	}
	.itemCate{
		display: flex;
		flex-direction: row;
		margin-top: 30rpx;
		.item{
			margin-left: 30rpx;
			width: 330rpx;
			height: 180rpx;
			background-color: #FFFFFF;
			border-radius: 16rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}
	}
	.allIncomes{
		padding: 40rpx 30rpx;
		font-size: 36rpx;
		font-weight: bold;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		.incomes{
			display: flex;
			flex-direction: column;
		}
	}
	.list_con{
		width: 670rpx;
		margin-top: 20rpx;
		margin-left: 20rpx;
		display: flex;
		flex-direction: column;
		background-color: #FFFFFF;
		border-radius: 12rpx;
		padding: 0 20rpx;
		.list_item{
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1rpx solid #eeeeee;
			padding: 20rpx 0;
			.icon{
				width: 80rpx;
				height: 80rpx;
			}
			.center{
				width: 100%;
				margin-left: 20rpx;
				display: flex;
				flex-direction: column;
				.center_row{
					width: 100%;
					// margin: 0 30rpx;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: space-between;
				}
			}
			.right{
				flex-shrink: 0;
				text{
					color: #000000;
					font-weight: bold;
				}
			}
		}
	}
</style>
